package com.hysoft.util;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class JdbcUtil {
    private Connection conn = null;
    /**
     * 绝对路径
     */

    public Connection getAccessConnection(String path) {
        String accessdriver = "sun.jdbc.odbc.JdbcOdbcDriver";
        String url = "jdbc:odbc:driver={Microsoft Access Driver (*.mdb, *.accdb)};DBQ="+path;
        try {
            Class.forName(accessdriver);
            conn = DriverManager.getConnection(url);
        } catch (SQLException e) {
            e.printStackTrace();
        } catch (ClassNotFoundException e){
            e.printStackTrace();
        }
        return conn;
    }



    private String  driver = "oracle.jdbc.driver.OracleDriver";
    public Connection getOracleConnection(String host,String port,String SID,String username,String password){
        try {
            Class.forName(driver);
            conn = DriverManager.getConnection("jdbc:oracle:thin:@"+host+":"+port+":"+SID,username,password);
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (SQLException e) {
            e.printStackTrace();
        }

        return conn;
    }
}
